import { IPSSystem } from '../../ipssystem';
import { IPSDEMethodDTO } from './ipsdemethod-dto';
import { IPSDEMethodDTOField } from './ipsdemethod-dtofield';
import { IPSSysMethodDTO } from '../../service/ipssys-method-dto';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSDEMethodDTOImpl extends PSModelObjectImpl implements IPSDEMethodDTO {
  get codeName(): string {
    return this.M.codeName;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get extendMode(): 0 | 2 {
    return this.M.extendMode != null ? this.M.extendMode : 0;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected psdemethoddtofields: IPSDEMethodDTOField[] | null = null;

  getPSDEMethodDTOFields(): IPSDEMethodDTOField[] | null {
    if (this.psdemethoddtofields == null) {
      this.psdemethoddtofields = this.fillChildListModel(this.M.getPSDEMethodDTOFields, 'dataentity.service.IPSDEMethodDTOField') as IPSDEMethodDTOField[];
    }
    return this.psdemethoddtofields;
  }

  get psDEMethodDTOFields(): IPSDEMethodDTOField[] | null {
    return this.getPSDEMethodDTOFields();
  }

  findPSDEMethodDTOField(objKey: any): IPSDEMethodDTOField | null {
    return this.getPSModel5('dataentity.service.IPSDEMethodDTOField', this.getPSDEMethodDTOFields(), objKey) as IPSDEMethodDTOField;
  }

  get sourceType(): 'DE' | 'DYNAMODEL' | 'DEACTIONINPUT' | 'DEFILTER' | 'REFDE' | 'DEDATASETINPUT' {
    return this.M.sourceType;
  }

  protected srcpssysmethoddto: IPSSysMethodDTO | null = null;

  getSrcPSSysMethodDTO(): IPSSysMethodDTO | null {
    if (this.srcpssysmethoddto != null) return this.srcpssysmethoddto;
    const value = this.M.getSrcPSSysMethodDTO;
    if (value == null) {
      return null;
    }
    const ipssystem = this.getParentPSModelObject('IPSSystem') as IPSSystem;
    if (ipssystem != null) {
      this.srcpssysmethoddto = ipssystem.findPSSysMethodDTO(value);
    }
    return this.srcpssysmethoddto;
  }

  get srcPSSysMethodDTO(): IPSSysMethodDTO | null {
    return this.getSrcPSSysMethodDTO();
  }

  getSrcPSSysMethodDTOMust(): IPSSysMethodDTO {
    const value = this.getSrcPSSysMethodDTO();
    if (value == null) {
      throw new Error('未指定源动态模型系统DTO');
    }
    return value;
  }

  get type(): 'DEFAULT' | 'DEACTIONINPUT' | 'DEFILTER' | 'DEDATASETINPUT' {
    return this.M.type;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get defaultMode(): boolean {
    return this.M.defaultMode != null ? this.M.defaultMode : false;
  }

  get cls(): string {
    return 'PSDEMethodDTOImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'dataentity.service.IPSDEMethodDTO') return true;
    return super.instanceof(cls);
  }
}
